//
//  MLAPropertySubletCell.m
//  MagicLampApp
//
//  Created by Zheng on 2018/12/20.
//  Copyright © 2018 zheng.magic.lamp.app. All rights reserved.
//

#import "MLAPropertySubletCell.h"
#import "MLAPropertySubletModel.h"

@implementation MLAPropertySubletCell {
    UILabel *titleLbl;
    UILabel *numberLbl;
    UILabel *areaLbl;
    UILabel *rentLbl;
    UILabel *endDateLbl;
    UILabel *startDateLbl;
    UILabel *typeLbl;
}

- (void)setModel:(MLAPropertySubletModel *)model {
    _model = model;
    
    startDateLbl.text = _model.sign_contract_time;
    endDateLbl.text = _model.expire_time;
    areaLbl.text = [NSString stringWithFormat:@"面积：%@m²",_model.area_size];
    numberLbl.text = [NSString stringWithFormat:@"商铺号：%@",_model.shop_number];
    titleLbl.text = _model.shop_address;
    rentLbl.text = [NSString stringWithFormat:@"房租：%@元/月",_model.money];

    if (_model.sublease_status.integerValue == 1) {
        _deleteBtn.hidden = NO;
        typeLbl.hidden = YES;
    } else if (_model.sublease_status.integerValue == 2) {
        _deleteBtn.hidden = YES;
        typeLbl.hidden = NO;
    }
    
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        titleLbl = [[UILabel alloc] init];
        titleLbl.font = CX_GetNormalFont(16);
        titleLbl.textColor = CX_GetColorTitle();
        [self.shadowView addSubview:titleLbl];
        [titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.mas_equalTo(19);
        }];

        numberLbl = [[UILabel alloc] init];
        numberLbl.font = CX_GetNormalFont(12);
        numberLbl.textColor = CX_GetColorTitle();
        [self.shadowView addSubview:numberLbl];
        [numberLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.equalTo(self->titleLbl.mas_bottom).offset(18);
        }];

        areaLbl = [[UILabel alloc] init];
        areaLbl.font = CX_GetNormalFont(12);
        areaLbl.textColor = CX_GetColorTitle();
        [self.shadowView addSubview:areaLbl];
        [areaLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.equalTo(self->numberLbl.mas_bottom).offset(9);
        }];

        rentLbl = [[UILabel alloc] init];
        rentLbl.font = CX_GetNormalFont(12);
        rentLbl.textColor = CX_GetColorTitle();
        [self.shadowView addSubview:rentLbl];
        [rentLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.equalTo(self->areaLbl.mas_bottom).offset(9);
        }];
        
        endDateLbl = [[UILabel alloc] init];
        endDateLbl.font = CX_GetNormalFont(12);
        endDateLbl.textColor = CX_GetColorBlue();
        [self.shadowView addSubview:endDateLbl];
        [endDateLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.equalTo(self->rentLbl.mas_bottom).offset(26);
        }];

        startDateLbl = [[UILabel alloc] init];
        startDateLbl.font = CX_GetNormalFont(10);
        startDateLbl.textColor = CX_GetColorHex(0x999999, 1);
        [self.shadowView addSubview:startDateLbl];
        [startDateLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15);
            make.top.mas_equalTo(24);
        }];
        
        typeLbl = [[UILabel alloc] init];
        typeLbl.font = CX_GetNormalFont(14);
        typeLbl.textColor = CX_GetColorHex(0x6B7178, 1);
        typeLbl.text = @"申请中";
        typeLbl.hidden = YES;
        [self.shadowView addSubview:typeLbl];
        [typeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15);
            make.bottom.mas_equalTo(-20);
        }];

        _deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_deleteBtn setTitle:@"申请转租" forState:UIControlStateNormal];
        [_deleteBtn setTitleColor:CX_GetColorBlue() forState:UIControlStateNormal];
        _deleteBtn.titleLabel.font = CX_GetNormalFont(14);
        _deleteBtn.layer.borderColor = CX_GetColorBlue().CGColor;
        _deleteBtn.layer.borderWidth = 1;
        _deleteBtn.layer.cornerRadius = 5;
        _deleteBtn.layer.masksToBounds = YES;
        _deleteBtn.hidden = YES;
        [self.shadowView addSubview:_deleteBtn];
        [_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15);
            make.bottom.mas_equalTo(-20);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(30);
        }];

        /*
         startDateLbl.text = @"2018.9.9 12：21";
         endDateLbl.text = @"2018.9.9到期";
         rentLbl.text = @"房租：4000元/月";
         areaLbl.text = @"面积：44m2";
         numberLbl.text = @"商铺号：A001";
         titleLbl.text = @"A栋302-01";
         */
    }
    return self;
}



@end
